{namespace lfe=SGalinski\Lfeditor\ViewHelpers}

<f:layout name="Default" />

<f:section name="selectItems">
	<f:render partial="SelectExtensionAndLanguageFile" arguments="{_all}" />
	<f:form id="mainMenuForm" action="changeSelection">
		<f:render partial="SelectLanguageAndReference" arguments="{_all}" />
		<f:render partial="SelectReferenceLanguage" arguments="{_all}" />
		<f:if condition="{constantTypeOptions}">
			<h2 class="uppercase">
				<f:translate key="select.constantType" />
			</h2>
			<f:form.select name="constantTypeSelection"
				value="{constantTypeSelection}"
				options="{constantTypeOptions}"
				additionalAttributes="{onchange: 'submitForm(\'mainMenuForm\')'}"
				/>
		</f:if>
		<f:render partial="SelectNumConstants" arguments="{_all}"/>
	</f:form>
</f:section>

<f:section name="main">
	<f:if condition="{constValues}">
		<h2 class="uppercase">
			<f:translate key="function.langfile.edit" />
		</h2>
		<p>
			<span id="tx-lfeditor-numberCur">{curConsts}</span> /
			<span id="tx-lfeditor-numberOf">{totalConsts}</span>
		</p>

		<f:form id="contentForm" action="editFileSave">
			<f:form.hidden name="buttonType" value="0" />
			<div class="tx-lfeditor-buttons">
				<f:if condition="{displayBackButton}">
					<f:form.submit value="{f:translate(key:'button.session.back')}" onclick="submitLanguageFileEdit(1)" />
				</f:if>
				<f:if condition="{displayNextButton}">
					<f:form.submit value="{f:translate(key:'button.session.next')}" onclick="submitLanguageFileEdit(2)" />
				</f:if>
				<f:form.submit id="tx-lfeditor-button-submit" value="{f:translate(key:'button.save')}" onclick="submitLanguageFileEdit(3)" />
				<f:form.submit value="{f:translate(key:'button.cancel')}" onclick="return confirmCancelFileEdit()" />
			</div>

			<f:for each="{constValues}" key="constKey" as="constValue" iteration="iterator">
				<fieldset class="tx-lfeditor-fieldset bgColor5 {lfe:extendedIf(condition: iterator.isOdd, or: parallelEdit, then: 'tx-lfeditor-fleft', else: 'tx-lfeditor-fright')}">
					<legend class="bgColor3 tx-lfeditor-constantMaxWidth400" title="{languageSelection}:{constKey}">
						{f:if(condition: '{languageSelection} == \'default\'', then: 'en', else: '{languageSelection}')}:{constKey}
					</legend>
					<lfe:extendedIf condition="{languageSelection} == {defaultLanguage}" and="{defaultLanguagePermission} != 1">
						<f:then>
							<f:form.textarea
								cols="80" rows="{numTextAreaRows}"
								value="{constValue.edit}"
								name="editFileTextArea[{languageSelection}][{constKey}]"
								lang="{f:if(condition: '{languageSelection} == \'default\'', then: 'en', else: '{languageSelection}')}"
								additionalAttributes="{readonly: ''}"
								class="tx-lfeditor-textarea" />
						</f:then>
						<f:else>
							<f:form.textarea
								cols="80" rows="{numTextAreaRows}"
								value="{constValue.edit}"
								name="editFileTextArea[{languageSelection}][{constKey}]"
								lang="{f:if(condition: '{languageSelection} == \'default\'', then: 'en', else: '{languageSelection}')}"
								class="tx-lfeditor-textarea" />
						</f:else>
					</lfe:extendedIf>
					<f:if condition="{constValue.default}">
						<p class="tx-lfeditor-defaultTranslation bgColor3">
							{constValue.default}
						</p>
					</f:if>
				</fieldset>
				<f:if condition="{parallelEdit}">
					<fieldset class="tx-lfeditor-fieldset bgColor5 tx-lfeditor-fright">
						<legend class="bgColor3 tx-lfeditor-constantMaxWidth400" title="{referenceLanguageSelection}:{constKey}">
							{f:if(condition: '{referenceLanguageSelection} == \'default\'', then: 'en', else: '{referenceLanguageSelection}')}:{constKey}
						</legend>
						<lfe:extendedIf condition="{referenceLanguageSelection} == {defaultLanguage}" and="{defaultLanguagePermission} != 1">
							<f:then>
								<f:form.textarea
									cols="80" rows="{numTextAreaRows}"
									value="{constValue.pattern}"
									name="editFileTextArea[{referenceLanguageSelection}][{constKey}]"
									lang="{f:if(condition: '{referenceLanguageSelection} == \'default\'', then: 'en', else: '{referenceLanguageSelection}')}"
									additionalAttributes="{readonly: ''}"
									class="tx-lfeditor-textarea" />
							</f:then>
							<f:else>
								<f:form.textarea
									cols="80" rows="{numTextAreaRows}"
									value="{constValue.pattern}"
									name="editFileTextArea[{referenceLanguageSelection}][{constKey}]"
									lang="{f:if(condition: '{referenceLanguageSelection} == \'default\'', then: 'en', else: '{referenceLanguageSelection}')}"
									class="tx-lfeditor-textarea" />
							</f:else>
						</lfe:extendedIf>
						<f:if condition="{constValue.default}">
							<p class="tx-lfeditor-defaultTranslation bgColor3">
								{constValue.default}
							</p>
						</f:if>
					</fieldset>
				</f:if>
			</f:for>

			<div class="tx-lfeditor-buttons">
				<f:if condition="{displayBackButton}">
					<f:form.submit value="{f:translate(key:'button.session.back')}" onclick="submitLanguageFileEdit(1)" />
				</f:if>
				<f:if condition="{displayNextButton}">
					<f:form.submit value="{f:translate(key:'button.session.next')}" onclick="submitLanguageFileEdit(2)" />
				</f:if>
				<f:form.submit value="{f:translate(key:'button.save')}" onclick="submitLanguageFileEdit(3)" />
				<f:form.submit value="{f:translate(key:'button.cancel')}" onclick="return confirmCancelFileEdit()" />
			</div>
		</f:form>
	</f:if>
</f:section>